To view these slides go to the workshop’s website.1
Created Spring 2021: Last updated May 18, 2021
To view these slides go to the workshop’s website.1
Learn how your organization can use R
Write your first R code!
See some highlights of the R ecosystem
I didn’t forget about quality improvement!
The materials we will go through as we play with R are focused around a simulated quality improvement project to help spark your imagination about how you could use R in your work from project conception to analysis and publication.
The workshop will be held on Zoom.
You’ll need the following during the workshop:
A computer with internet connection
An RStudio Cloud account—free
If you would like to some additional preparation for the workshop, I recommend the following:
Introduction ~30 minutes
Systems check ~15 minutes
Play ~30 minutes
Wrap Up and Discussion ~20 minutes
It’s a programming language.
It’s software.
It’s free!
You can run it locally.
You can run it in the cloud.
You can run it on a high performance computing cluster!
There’s a great community around the world using R!!
You can reproduce your work.
You can share every step of your analysis.
You can reuse your code for many projects!
You can use other’s code for many projects!
# Text after a hash is a comment # It is not run by the computer # Can be used as notes to you (or future you!) # Here are a few simple calculations 1 + 1
## [1] 2
2 * 3
## [1] 6
4^2
## [1] 16
You can manipulate strings of text.
host <- "Mara" greeting <- "Hello World" paste0(greeting, " from ", host, "!")
## [1] "Hello World from Mara!"
Excel
Google Sheets
SAS
SPSS
Stata
Lot’s more
You might have data like this?
How do you get it into R? Like this!
#From Excel
fake_data <-
read_excel("./data/qi_spreadsheet_workshop.xlsx",
sheet = "scatter")
| count | time | resident | factor_service |
|---|---|---|---|
| 1 | 16.225 | Pediatrics | 0.55 |
| 2 | 15.675 | Pediatrics | 0.55 |
| 3 | 16.225 | Pediatrics | 0.55 |
| 4 | 11.550 | Pediatrics | 0.55 |
| 5 | 5.775 | Pediatrics | 0.55 |
How did I make that table??
head(fake_data, 5) %>%
knitr::kable() %>%
kable_classic(full_width = F,
html_font = "Cambria")
| count | time | resident | factor_service |
|---|---|---|---|
| 1 | 16.225 | Pediatrics | 0.55 |
| 2 | 15.675 | Pediatrics | 0.55 |
| 3 | 16.225 | Pediatrics | 0.55 |
| 4 | 11.550 | Pediatrics | 0.55 |
| 5 | 5.775 | Pediatrics | 0.55 |
You can make plots.
You can make plots—with statistical overlay.
The code to transform the plot into an interactive plot is a single function ggplotly()!
With R you can create documents in different formats:
Book Made with R
You can mix programming languages together
R and Python
R and Python and SQL
R and Python and SQL and Bash
…
You use R from start to finish with a project
You can use it for a single part of your project—eg making plots.
You can use it alongside other software like Tableau and REDCap
You could hire someone to do R work for you in a day.
You probably already have folks at your institution who are R pros!
People can upskill and learn R!
Log into Rstudio Cloud
If you don’t have a link to the materials, message Mara directly in the Zoom chat with your email
Raise hand in zoom if you are having trouble
Take this survey
If you are an advanced user, open up the QI_playground.Rmd and start playing around
Once you are in RStudio Cloud, click on the project called CIC_2021_QI_R_Workshop
For this workshop we will be using RStudio Cloud.
Why? Because there is nothing that you need to download!
You don’t need to use RStudio to use R, but I do!
RStudio on your computer and RStudio Cloud look very similar.
R and RStudio are free to download to your computer.
To knit something in R means to transform it from the raw text and code into a nice output like a PDF or slides. One source material can be knit into many different outputs—from the same source I might make a website, a word document, or a set of slides.
Click there to make a new file.
After you have selected R Markdown, you will get a pop up like below.
Title it Hello World! Hit “OK”
Your new file should look something like this.
An Rmd file allows you to mix code and text in a single document.
You can then knit an Rmd file to many different outputs.
The YAML header contains the special instructions on how to create the output document. We won’t do much with it here today, but it is a very powerful way to make your Rmd file as bespoke as you want it!
Code chunks are where the code will go.
Code chunks have a gray background.
#This is a code chunk! #Here is a simple calculation 1 + 2
## [1] 3
You can run a code chunk by pressing the green play button.
The text areas are the white background areas below the YAML header.
You can use R Markdown syntax to generate rich text formating from simple symbols like the examples below.
Press the knit button.
You’ll be asked to save the file; name it hello_world
Go to your file pane. Open the Demo.Rmd file.
During the workshop we will work through the Demo.Rmd.
Ask questions in the Zoom chat or raise your hand.5
After finishing up the Demo.Rmd, we will move on to the QI part.
Finally!